package com.wedimob.scrapper.network;

import java.io.IOException;

import org.jsoup.Connection.Response;
import org.jsoup.Jsoup;

/**
 * basic connexion strategy using jsoup.
 * 
 * @author melouadi
 * 
 */
public class JSoupConnectionStrategy implements ConnectionStrategy {

	/**
	 * basic factory.
	 * 
	 * @return strategy
	 */
	public static ConnectionStrategy create() {
		return new JSoupConnectionStrategy();
	}

	/**
	 * default user agent.
	 * 
	 */
	private static final String USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64)"
			+ " AppleWebKit/535.21 (KHTML, like Gecko)"
			+ " Chrome/19.0.1042.0 Safari/535.21";

	@Override
	public final Response get(final String aUrl, final int aTimeout)
			throws IOException {
		return Jsoup.connect(aUrl).timeout(aTimeout).userAgent(USER_AGENT)
				.ignoreContentType(true).execute();
	}

}
